



#include "Public.h"


void Init_Timer14_Config(void)
{
  
  NVIC_InitTypeDef NVIC_InitStructure ={0};  
  TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure={0}; 
  
  
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM14, ENABLE); //配置时钟
  
  // Time base configuration 
  TIM_TimeBaseStructure.TIM_Period    = 48000;   //
  TIM_TimeBaseStructure.TIM_Prescaler = 0;
  TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
  TIM_TimeBaseStructure.TIM_CounterMode   = TIM_CounterMode_Up;
  TIM_TimeBaseInit(TIM14, &TIM_TimeBaseStructure);
  

  // Enable the TIM14 gloabal Interrupt 
  NVIC_InitStructure.NVIC_IRQChannel = TIM14_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
  
  TIM14->CCR1 = 3500;

  TIM_ClearITPendingBit(TIM14, TIM_IT_CC1);
  TIM_ClearFlag(TIM14, TIM_FLAG_CC1); // 清除计数器中断标志位
  
  TIM_ITConfig(TIM14, TIM_IT_CC1, ENABLE);
  
  TIM_Cmd(TIM14, ENABLE);
}


